<%--
  Created by IntelliJ IDEA.
  User: 494418174
  Date: 2020/3/9 0009
  Time: 12:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/favicon.ico">
    <link rel="stylesheet" href="/layui/css/layui.css">
</head>
<body style="height: 100%; margin: 0">

<div style="margin-top: 20px"> </div>

<form class="layui-form" method="post" id="searchFrm">

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">年份:</label>
            <div class="layui-input-inline" style="padding: 5px">
                <input type="text" name="selYear" id="selYear" required  lay-verify="required"
                       class="layui-input layui-input-inline"
                       placeholder="请输入年份" style="height: 30px;border-radius: 10px;width: 280px">
            </div>
        </div>

        <div class="layui-inline" style="text-align: center">
            <button type="button"
                    class="layui-btn layui-btn-normal layui-icon layui-icon-search layui-btn-radius layui-btn-sm"
                    lay-submit  lay-filter="doSearch" style="margin-top: 4px">查询
            </button>
        </div>
    </div>

</form>

<div id="container" style="height: 90%;margin-top: 20px;"></div>


<script type="text/javascript" src="/js/echarts.min.js"></script>
<script src="/layui/layui.js"></script>
<script type="text/javascript">

    layui.use(['form','layer','jquery','laydate'], function() {
        var form = layui.form
        var layer = layui.layer
        var $ = layui.jquery
        var laydate = layui.laydate

        // 对日期年份进行初始化
        laydate.render({
            elem:"#selYear"
            , type :"year"
            , value : new Date()
        })

        // 查询
        form.on("submit(doSearch)",function(data) {

            // 根据年份查询当前年度 业务员的销售额
            $.post('/stat/priceByYear',{"year":data.field.selYear},function (r) {
                if(r.code == 0){
                    showInfo(r.data)
                }else{
                    layer.msg(r.msg)
                }
            })


            return false;
        })

        function showInfo(data) {

            var dom = document.getElementById("container");
            var myChart = echarts.init(dom);
            var app = {};
            option = null;
            option = {
                title: {
                    text: data.year + '年度业务员销售额',
                    subtext: '真实有效',
                    left: 'center'
                },
                color: ['#3398DB'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    }
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        data: data.name,
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value'
                    }
                ],
                series: [
                    {
                        name: '销售总金额',
                        type: 'bar',
                        barWidth: '60%',
                        data: data.value
                    }
                ]
            };
            ;
            if (option && typeof option === "object") {
                myChart.setOption(option, true);
            }
        }


    })

</script>

</body>
</html>
